package cn.tl.hrm.controller;

import cn.tl.hrm.doc.CourseDoc;
import cn.tl.hrm.dto.CourseSearchParamDTO;
import cn.tl.hrm.service.ICourseElasticSearchService;
import cn.tl.hrm.util.AjaxResult;
import cn.tl.hrm.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//针对课程的es
@RestController
@RequestMapping("/course")
public class CourseEsController {
    @Autowired
    private ICourseElasticSearchService courseElasticSearchService;

    //搜索课程
    @PostMapping("/searchCourse")
    public AjaxResult searchCourse(@RequestBody CourseSearchParamDTO dto){
        PageList<CourseDoc> pageList = courseElasticSearchService.searchCourse(dto);
        return AjaxResult.me().setResultObj(pageList);
    }
    //添加课程到ES
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CourseDoc doc){
        courseElasticSearchService.add(doc);
        return AjaxResult.me();
    }
}
